package com.gxa.modules.sys.controller;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.gxa.common.utils.Result;
import com.gxa.modules.sys.entity.RestTime;
import com.gxa.modules.sys.service.RestTimeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

@Api(tags = "作息时间接口")
@RestController
public class RestTimeController {

    @Autowired
    private RestTimeService restTimeService;

    @ApiOperation(value = "作息时间查询")
    @GetMapping("/restTime")
    public Result queryAll(){
        try {
            List<RestTime> restTimes = restTimeService.queryAll();
            return new Result().ok(restTimes);
        } catch (Exception e) {
            return new Result().error("查询失败");
        }
    }
    @ApiOperation(value = "修改营业时间接口")
    @PutMapping("/update/businessTime")
    public Result updateBusinessTime(String businessStartTime,String businessEndTime){
        try {
            this.restTimeService.updateBusinessTime(businessStartTime,businessEndTime);
            return new Result().ok();
        } catch (Exception e) {
            return new Result().error("修改失败");
        }
    }
    @ApiOperation(value = "修改预约时间接口")
    @PutMapping("/update/appointmentTime")
    public Result updateAppointmentTime(String appointmentTime){
        try {
            this.restTimeService.updateAppointmentTime(appointmentTime);
            return new Result().ok();
        } catch (Exception e) {
            return new Result().error("修改失败");
        }
    }
    @ApiOperation(value = "修改停业时间接口")
    @PutMapping("/update/closureTime")
    public Result updateClosureTime(String closureStartTime,String closureEndTime){
        try {
            this.restTimeService.updateClosureTime(closureStartTime,closureEndTime);
            return new Result().ok();
        } catch (Exception e) {
            return new Result().error("修改失败");
        }
    }
}
